package com.ruoyi.product.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ruoyi.common.utils.Long2StringHandle;
import com.ruoyi.product.tree.DataTreeRes;
import lombok.Data;
import java.util.List;

@Data
public class ClassifyDTO implements DataTreeRes<ClassifyDTO>,Comparable<ClassifyDTO> {

    @JsonSerialize(using = Long2StringHandle.class)
    private Long keyId;

    private Long parentId;
    /**
     * 分类名
     */
    private String name;

    /**
     * 层级
     */
    private Integer depth;

    /**
     * 显示顺序
     */
    private Integer orderNum;

    private List<ClassifyDTO> childList;

    @Override
    public int compareTo(ClassifyDTO o) {
        if (this.orderNum > o.getOrderNum()) {
            return 1;
        }else if (this.orderNum < o.getOrderNum()) {
            return -1;
        }else {
            return 0;
        }
    }
}
